import 'package:flutter/material.dart';

/// 应用主题颜色定义
class AppColors {
  // 主色调
  static const Color primary = Color(0xFF8B4513); // 棕色，代表传统文化
  static const Color primaryLight = Color(0xFFD2B48C); // 浅棕色
  static const Color primaryDark = Color(0xFF654321); // 深棕色
  
  // 辅助色
  static const Color secondary = Color(0xFFDAA520); // 金色，代表珍贵文化
  static const Color secondaryLight = Color(0xFFFFD700);
  static const Color secondaryDark = Color(0xFFB8860B);
  
  // 功能色
  static const Color success = Color(0xFF4CAF50);
  static const Color warning = Color(0xFFFF9800);
  static const Color error = Color(0xFFF44336);
  static const Color info = Color(0xFF2196F3);
  
  // 中性色
  static const Color background = Color(0xFFFAFAFA);
  static const Color surface = Color(0xFFFFFFFF);
  static const Color onBackground = Color(0xFF212121);
  static const Color onSurface = Color(0xFF424242);
  
  // 文本色
  static const Color textPrimary = Color(0xFF212121);
  static const Color textSecondary = Color(0xFF757575);
  static const Color textHint = Color(0xFFBDBDBD);
  
  // 边框色
  static const Color border = Color(0xFFE0E0E0);
  static const Color divider = Color(0xFFEEEEEE);
  
  // 阴影色
  static const Color shadow = Color(0x1A000000);
  
  // 渐变色
  static const LinearGradient primaryGradient = LinearGradient(
    colors: [primary, primaryLight],
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
  );
  
  static const LinearGradient secondaryGradient = LinearGradient(
    colors: [secondary, secondaryLight],
    begin: Alignment.topLeft,
    end: Alignment.bottomRight,
  );
  
  // 卡片颜色
  static const Color cardBackground = Color(0xFFFFFFFF);
  static const Color cardShadow = Color(0x0F000000);
  
  // 状态颜色
  static const Color active = Color(0xFF4CAF50);
  static const Color inactive = Color(0xFF9E9E9E);
  static const Color disabled = Color(0xFFE0E0E0);
  
  // 特殊颜色
  static const Color heritage = Color(0xFF8B4513); // 非遗主题色
  static const Color culture = Color(0xFFDAA520); // 文化主题色
  static const Color traditional = Color(0xFF654321); // 传统主题色
}

/// 颜色工具类
class ColorUtils {
  /// 根据亮度调整颜色
  static Color adjustBrightness(Color color, double factor) {
    return Color.fromARGB(
      color.alpha,
      (color.red * factor).round().clamp(0, 255),
      (color.green * factor).round().clamp(0, 255),
      (color.blue * factor).round().clamp(0, 255),
    );
  }
  
  /// 获取颜色的对比色
  static Color getContrastColor(Color color) {
    final luminance = color.computeLuminance();
    return luminance > 0.5 ? Colors.black : Colors.white;
  }
  
  /// 获取半透明颜色
  static Color withOpacity(Color color, double opacity) {
    return color.withOpacity(opacity);
  }
}